package com.mark.admin.job;

import com.mark.admin.service.ReviewCrawlerArticleService;
import com.mark.common.quartz.AbstractJob;
import lombok.extern.log4j.Log4j2;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Description :  爬网程序审阅文章作业
 * @Author :  Markburt
 * @CreateDate :  2020/3/7$ 下午 03:23$
 * @UpdateUser :  Markburt
 * @UpdateDate :  2020/3/7$ 下午 03:23$
 * @UpdateRemark :  Project Build
 * @Version :  1.0
 */
@Component
@DisallowConcurrentExecution
@Log4j2
@SuppressWarnings("all")
public class CrawlerReviewArticleJob extends AbstractJob {


    @Autowired
    private ReviewCrawlerArticleService reviewCrawlerArticleService;
    /**
     * 触发
     * @return
     */
    @Override
    public String[] triggerCron() {
        return new String[]{" 0 0/1 * * * ?"};
    }


    /***
     *执行内部定时任务
     * @param jobExecutionContext
     * @throws JobExecutionException
     */
    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        long currentTimeMillis = System.currentTimeMillis();
        log.info("开始定时任务执行");
        try {
            reviewCrawlerArticleService.autoReivewArticleByCrawler();
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("定时任务结束，耗时:{}",System.currentTimeMillis()-currentTimeMillis);
    }


    /**
     * 描述触发器
     * @return
     */
    @Override
    public String descTrigger() {
        return "每天晚上11:30分执行";
    }
}
